syscall: fcntl param3 type to uintptr_t#18810
Merged
acassis merged 1 commit intoapache:masterfrom Apr 27, 2026
Merged
Conversation
Fixing incorrect 32->64bit pointer conversion Signed-off-by: Jari Nippula <jari.nippula@tii.ae>
xiaoxiang781216
approved these changes
Apr 27, 2026
acassis
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fcntl syscall causes crash in RV64 build. Casting int to uintptr_t causes
32-bit user side pointer to end up
0xffffffffc0xxxxxxinstead of0x000000c0xxxxxx.The parm3 in fcntl syscall API shall be uintptr_t instead of int
"fcntl","fcntl.h","","int","int","int","...","uintptr_t"Impact
Kernel crash in case of file lock used
Crash occurs in file_lock_normalize, where A1 contains incorrect address to reference.
Conversion from int to uintptr_t in PROXY_fcntl.c causes upper word to be 0xffffffff because the 32-bit int 0xc0xxxxxx has bit31 set (negative value).
Testing
Build target: RISC-V mpfs based custom hardware.
File lock feature enabled (CONFIG_FS_LOCK_BUCKET_SIZE) and used to
protect against simultaneous accesses.
Without the fix the kernel crash occurs:
[CPU1] riscv_exception: EXCEPTION: Load page fault. MCAUSE: 000000000000000d, EPC: 00000000a0012c22, MTVAL: ffffffffc2008e78With fixed fcntl syscall the file lock works properly, no crash occurs.